//
//  STTabBarController.m
//  OCVVeibo
//
//  Created by leergou on 16/7/19.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

#import "STTabBarController.h"
#import "STHomeController.h"
#import "STMessageController.h"
#import "STDiscoverController.h"
#import "STProfileController.h"
#import "STTabBar.h"
#import "STComposeBlurView.h"



@interface STTabBarController ()

@end

@implementation STTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    STTabBar *tabBar = [[STTabBar alloc] initWithFrame:CGRectZero];
    
    tabBar.composeBtnClick= ^(){
        
        // 点击撰写按钮，加载模糊效果界面
        NSLog(@"composeClick");
        
        STComposeBlurView *composeView = [[STComposeBlurView alloc] init];
        
        [composeView showWithTarget:self];
    };
    
    [self setValue:tabBar forKey:@"tabBar"];
    
    // 设置子控制器
    [self setupChildVc];
}

#pragma mark - 设置子控制器
- (void)setupChildVc{
    
    UINavigationController *homeNav = [[UINavigationController alloc] initWithRootViewController:[[STHomeController alloc] init]];
    
    [self setupViewController:homeNav title:@"首页" imgNormal:@"tabbar_home" imgSelected:@"tabbar_home_selected"];
    
    UINavigationController *messageNav = [[UINavigationController alloc] initWithRootViewController:[[STMessageController alloc] init]];
    
    [self setupViewController:messageNav title:@"消息" imgNormal:@"tabbar_message_center" imgSelected:@"tabbar_message_center_selected"];
    
    UINavigationController *discoverNav = [[UINavigationController alloc] initWithRootViewController:[[STDiscoverController alloc] init]];
    [self setupViewController:discoverNav title:@"发现" imgNormal:@"tabbar_discover" imgSelected:@"tabbar_discover_selected"];
    
    UINavigationController *profileNav = [[UINavigationController alloc] initWithRootViewController:[[STProfileController alloc] init]];
    
    [self setupViewController:profileNav title:@"我" imgNormal:@"tabbar_profile" imgSelected:@"tabbar_profile_selected"];
    
    self.viewControllers = @[homeNav, messageNav, discoverNav, profileNav];
}

#pragma mark - 设置tabBarItem
- (void)setupViewController:(UINavigationController *)nav title:(NSString *)title imgNormal:(NSString *)imgNormal imgSelected:(NSString *)imgSelected{
    
    nav.tabBarItem.title = title;
    nav.title = title;
    [nav.tabBarItem setImage:[UIImage imageNamed:imgNormal]];
    [nav.tabBarItem setSelectedImage:[UIImage imageNamed:imgSelected]];
}


@end










